<?php
/**
 * Created by PhpStorm.
 * User: Simon
 * Date: 17/07/27
 * Time: 上午11:20
 */

namespace App\Util;

/**
 * 签名Util
 *
 * Class encryption
 *
 * @package App\Util
 */
class SignUtil
{

    /**
     * 签名
     *
     * @param array $request
     *
     * @return string
     */
    public static function sign(array $request)
    {
        ksort($request);
        $return = '';
        foreach ($request as $k => $v) {
            if ($v != '') {
                if ($k == 'sign') {
                    continue;
                }
                if (!empty($return)) {
                    $return .= '&' . $k . '=' . $v;
                } else {
                    $return .= "$k=$v";
                }
            } else {
                unset($request[$k]);
            }
        }
        return $return;
    }

}